<template>
  <iframe class="onekit-web-view"
          :class="onekitClass"
          :style="onekitStyle"
          :src="url"
          :id="onekitId">
  </iframe>
</template>

<script>
import weixin_behavior from "../../behaviors/weixin_behavior"
import onekit_behavior from "../../behaviors/onekit_behavior"
export default {
  name: "onekit-web-view",
  mixins: [weixin_behavior, onekit_behavior],
  props: {
    "onekit-id": { type: String, default: `id${new Date().getTime()}` },
    src: String
  },
  data () {
    return {
      url: null
    }
  },
  mounted () {
    //document.getElementById(this.onekitId).addEventListener("load",(res)=>console.log("load",res))
    document.getElementById(this.onekitId).addEventListener("error", (res) => console.error("[OneKit]", "Web-View", res))
    this.src_(this.src);
  },
  watch: {
    src (src) {
      this.src_(src)
    }
  },
  methods: {
    src_ (src) {
      this.url = src
    }
  }
}
</script>

<style>
</style>
